<template>
  <div id="home">
    <el-container>
      <el-header
        ><h2>后台管理系统</h2>
        <el-button @click="quit" class="quit">退出</el-button>
      </el-header>
      <el-container>
        <el-aside :width="isCollapse ? '64px' : '200px'">
          <p class="show" @click="showisCollapse">|||</p>
          <el-menu
            v-model="isCollapse"
            :collapse="isCollapse"
            default-active="2"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            router
          >
            <el-submenu
              :index="item.id + ''"
              v-for="item in list"
              :key="item.id"
            >
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.authName }}</span>
              </template>

              <el-menu-item
                :index="'/' + menus.path"
                v-for="menus in item.children"
                :key="menus.id"
                >{{ menus.authName }}</el-menu-item
              >
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>


<script>
export default {
  props: [],
  data() {
    return {
      isCollapse: false,
      list: [],
    };
  },
  methods: {
    showisCollapse() {
      this.isCollapse = !this.isCollapse;
    },
    quit() {
      this.$store.commit("quit");
      this.$router.push("/login");
    },
  },
  computed: {},
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMounte() {},
  mounted() {
    this.$http.get("menus").then((res) => {
      this.list = res.data;
    });
  },
  beforeUpdate() {},
  updated() {},
  beforeDistroy() {},
  distroyed() {},
};
</script>


<style scoped>
.show {
  width: 100%;
  text-align: center;
}
.quit {
  height: 40px;
  margin-top: 10px;
}
.el-header {
  display: flex;
  justify-content: space-between;
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}
.el-container {
  height: 100%;
}
</style>